package com.starblink.library.widget.subscription

import android.view.View
import com.starblink.android.basic.widget.dialog.BaseBottomSheetFragment
import com.starblink.library.widget.databinding.DialogSubsEmailSetBinding

/**
 * 邮件显示或提示弹窗
 *  Create by yuanl at 2023/10/7
 **/
class SubsEmailSetDF: BaseBottomSheetFragment() {

    var subsEmailVal: String? = null
    var registerEmail: String? = null

    private val binding by lazy {
        DialogSubsEmailSetBinding.inflate(layoutInflater)
    }

    override fun getBindingRootView(): View = binding.root

    override fun initView() {
        binding.btnClose.setOnClickListener {
            dismissNow()
        }
        val email = subsEmailVal.orEmpty().ifEmpty { registerEmail }
        binding.btn.setOnClickListener {
            requireActivity().showSubsEmailInputDialog(email = email) {
                dismissNow()
            }
        }
        if (email?.isNotEmpty() == true) {
            binding.tvTip.text = "We will alert you through your email when there are discount messages."
            binding.tvEmail.text = email
            binding.btn.text = "Manage My Alerts"
        }
    }
}